﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._20_备忘录模式
{
    /// <summary>
    /// 原发器（文本编辑器）
    /// </summary>
    public class TextEditor
    {
        public string Content { get; set; } 

        /// <summary>
        /// 创建备忘录
        /// </summary>
        /// <returns></returns>
        public EditorMemento Save()
        {
            Console.WriteLine($"创建内容。。：{Content}");
            return new EditorMemento(Content);
        }
        /// <summary>
        /// 恢复备忘录
        /// </summary>
        /// <param name="memento"></param>
        public void Restore(EditorMemento memento)
        {
            Content = memento.Content;
            Console.WriteLine($"恢复内容：{Content}");
        }

    }
}
